<?php
/**
 * Created by PhpStorm.
 * User: 小蛮哼哼哼
 * Email: 243194993@qq.com
 * Date: 2021/12/31
 * Time: 17:09
 * motto: 现在的努力是为了小时候吹过的牛逼！
 */

declare(strict_types=1);

namespace app\text\controller;

use app\BaseController;
use app\common\business\Goods;
use app\common\business\Member;
use app\common\business\MemberPaylog;
use app\common\lib\ArrClass;
use app\common\lib\Show;
use app\common\lib\Status;
use app\common\lib\Str;
use app\common\model\MallGoods;
use app\common\model\MallGroupsGoods;
use app\common\model\MallGroupsOrder;
use think\cache\driver\Redis;
use think\Exception;
use think\facade\Log;

class Index extends BaseController
{
    public function index(){
        $objClass = ArrClass::payAttr();
        $obj = ArrClass::initClass('wx',$objClass,[],true);
        $data = [
            'body' => '腾讯充值中心-QQ会员充值',
            'out_trade_no' => Str::Random(),
            'total_fee' => 88,
            'spbill_create_ip' => $this->request->ip(), // 可选，如不传该参数，SDK 将会自动获取相应 IP 地址
            'notify_url' => 'https://pay.weixin.qq.com/wxpay/pay.action', // 支付结果通知网址，如果不设置则会使用配置里的默认地址
            'trade_type' => 'JSAPI', // 请对应换成你的支付方式对应的值类型
            'openid' => 'op7A_42tDuuAFC9zb5uP74zzSzes',
        ];
        //$res = $obj->order($data);
        $res = $obj->jssdk("wx31172245384430d0dbe827659697d60000");
        dump($res);exit();
    }




    public function demo(){
//        $redis = new Redis();
//        $con =$redis->connect('127.0.0.1',6379);
//
//        $goods= (new Goods())->getGoodsInfo('op7A_44FkQrhPU44QhWsGo1LgxF0',[['id','=',42]],'*');
//        //$redis->delete('shopgoods_10');
//        if(!$redis->exists('shopgoods_10')){
//            $redis->set('shopgoods_10',0);
//        }
//        if($redis->inc("shopgoods_10",1) > $goods['stock']){
//            echo "写入失败";
//            Log::error('写入失败');
//        }else{
//            (new MallGoods())->where("id=42")->dec('stock',1)->update();
//            (new MallGoods())->where("id=42")->inc('sales',1)->update();
//            $redis->dec("shopgoods_10",1);
//            echo "写入成功";
//            Log::error('写入成功');
//        }
    }
}